define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'mall.applygoods/index',
        mendian_url: 'mall.mendian/index',
        edit_url: 'mall.applygoods/edit',
        delete_url: 'mall.applygoods/delete',
        export_url: 'mall.applygoods/export',
        modify_url: 'mall.applygoods/modify',
        stock_url: 'mall.applygoods/stock',
    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                toolbar: ['refresh',
                    [],
                    'export'],
                cols: [[
                    {type: "checkbox"},
                    {field: 'id', width: 80, title: 'ID'},
                    {field: 'sort', width: 80, title: '排序', edit: 'text',search: false,},
                    {field: 'catename', minWidth: 80, title: '商品分类',search: false},
                    {field: 'title', minWidth: 80, title: '商品名称'},
                    {field: 'logo', minWidth: 80, title: '分类图片', search: false, templet: ea.table.image},
                    {field: 'market_price', width: 100, title: '市场价',search: false, templet: ea.table.price},
                    {field: 'total_stock', width: 100, title: '库存统计',search: false,},
                    {field: 'stock', width: 100, title: '剩余库存',search: false,},
                    {field: 'create_time', minWidth: 80, title: '申请时间', search: 'range'},
                    {
                        width: 280,
                        title: '操作',
                        templet: ea.table.tool,
                        operat: [
                            [{
                                text: '审核',
                                url: init.stock_url,
                                method: 'open',
                                auth: 'stock',
                                class: 'layui-btn layui-btn-xs layui-btn-normal',
                            }],
                            'delete']
                    }
                ]],
            });

            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
        stock: function () {
            ea.listen();
        },
    };
    return Controller;
});